<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>Crew Intranet: JMS</title>
            </f:facet>
        </h:head> 

        <h:body>
            <ui:composition template="./template.xhtml">
                <ui:define name="top">

                </ui:define>
                <ui:define name="left">
                    <h:form>
                        <p:menu my="true" style="width:210px">
                            <p:menuitem value="Configuration" action="#{redirectionBean.getRedirectionMigrationDBConfigACCESS}" 
                                        styleClass="#{view.viewId == '/migrationdbconfigaccess.xhtml'
                                                      ? 'ui-state-active menuItemSelectionner' : ''}"
                                        icon="ui-icon-home"/> 
                            <p:submenu label="Access" >  

                                <p:menuitem value="Transfer des données " action="#{redirectionBean.getRedirectionMigrationDBACCESS}" 
                                            styleClass="#{view.viewId == '/migrationdbaccess.xhtml'
                                                          ? 'ui-state-active menuItemSelectionner' : ''}"
                                            icon="ui-icon-star"/>  
                            </p:submenu>
                            <p:submenu label="Sql serveur">  

                                <p:menuitem value="Transfer des données" action="#{redirectionBean.getRedirectionAffectationsJMS}" icon="ui-icon-suitcase" />   
                            </p:submenu>    
                        </p:menu>
                    </h:form>
                </ui:define>
                <ui:define name="content">
                    <h:form id="formMessage">
                        <p:growl id="message" />
                        <p:growl id="messageGrow" showDetail="true" />
                    </h:form>
                    <h:form id="formeListBesoin">
                        <p:panel header="Employé" >
                            <f:facet name="header">
                                Migration de la base <em>Access</em>
                                
                                <p:commandButton value="Enregistrer les personnels dans la base" icon="ui-icon-check"
                                                 action="#{migrationdbaccessBean.enregistrementGeneral}"
                                                     />
                            </f:facet>

                            <p:commandButton value="Lancer la migration" id="btnStartMigration"
                                             disabled="#{migrationdbaccessBean.lancement}"
                                             onclick="pbAjax.start()"
                                             immediate="true"
                                             action="#{migrationdbaccessBean.changeLancement}"
                                             styleClass="ui-priority-primary" style="margin-right: 100px;"
                                             update=":formeListBesoin:btnStartMigration, :formeListBesoin:availablePersonnelAccess "
                                             />

                            <p:progressBar widgetVar="pbAjax" ajax="true" value="#{migrationdbaccessBean.progress}" labelTemplate="{value}%" styleClass="animated">  
                                <p:ajax event="complete" listener="#{migrationdbaccessBean.onComplete}" update=":formMessage:messageGrow" />  
                            </p:progressBar>
                            <p:fieldset legend="Personnel de la base access"  >  

                                <p:dataTable id="availablePersonnelAccess" 
                                             paginator="true" rows="10"
                                             rowsPerPageTemplate="5,10,15"
                                             rowKey="#{personnelAccess.IDpersonne}"
                                             var="personnelAccess" value="#{migrationdbaccessBean.personnelDeLaBaseAccessT}">  
                                    <p:column style="width:20px" >  
                                        <h:outputText id="dragIcon"  
                                                      styleClass="ui-icon ui-icon-arrow-4" />  
                                        <p:draggable for="dragIcon" revert="true"  />  
                                    </p:column>  

                                    <p:column headerText="Matricule">  
                                        <h:outputText value="#{personnelAccess.IDpersonne}" />  
                                    </p:column>  

                                    <p:column headerText="Nom">  
                                        <h:outputText value="#{personnelAccess.nom}" />  
                                    </p:column>  

                                    <p:column headerText="Prenom">  
                                        <h:outputText value="#{personnelAccess.prenom}" />  
                                    </p:column>  

                                    <p:column headerText="Date de naissance">  
                                        <h:outputText value="#{personnelAccess.datenaissance}"  >
                                            <f:convertDateTime pattern="dd/MM/yyyy" />
                                        </h:outputText>
                                    </p:column>  
                                </p:dataTable>

                            </p:fieldset>
                            <h:panelGrid columns="4">
                                <!--<h:panelGrid columns="2">-->
                                <p:fieldset id="selectPersonelMission" legend="Mission" >
                                    <p:outputPanel id="dropAreaMission">
                                        <h:outputText value="!!!Deplacer ici!!!"  
                                                      rendered="#{empty migrationdbaccessBean.personnelMissionT}"  
                                                      style="font-size:24px;" /> 
                                        <p:dataTable var="personnelAccess" 
                                                     paginator="true" rows="5"
                                                     rowsPerPageTemplate="5,10,15"
                                                     value="#{migrationdbaccessBean.personnelMissionT}"   
                                                     rendered="#{not empty migrationdbaccessBean.personnelMissionT}">  

                                            <p:column headerText="Matricule">  
                                                <h:outputText value="#{personnelAccess.IDpersonne}" />  
                                            </p:column>  

                                            <p:column headerText="Nom">  
                                                <h:outputText value="#{personnelAccess.nom}" />  
                                            </p:column>  

                                            <p:column headerText="Prenom">  
                                                <h:outputText value="#{personnelAccess.prenom}" />  
                                            </p:column>   

                                        </p:dataTable>  
                                    </p:outputPanel>
                                </p:fieldset>
                                <p:fieldset id="selectPersonelAffectation" legend="Compagnie"  >

                                    <p:outputPanel id="dropAreaAffectation">

                                        <h:outputText value="!!!Deplacer ici!!!"  
                                                      rendered="#{empty migrationdbaccessBean.personnelAffectationT}"  
                                                      style="font-size:24px;" /> 
                                        <p:dataTable var="personnelAccess" 
                                                     paginator="true" rows="5"
                                                     rowsPerPageTemplate="5,10,15"
                                                     value="#{migrationdbaccessBean.personnelAffectationT}"   
                                                     rendered="#{not empty migrationdbaccessBean.personnelAffectationT}">  

                                            <p:column headerText="Matricule">  
                                                <h:outputText value="#{personnelAccess.IDpersonne}" />  
                                            </p:column>  

                                            <p:column headerText="Nom">  
                                                <h:outputText value="#{personnelAccess.nom}" />  
                                            </p:column>  

                                            <p:column headerText="Prenom">  
                                                <h:outputText value="#{personnelAccess.prenom}" />  
                                            </p:column>   

                                        </p:dataTable>  
                                    </p:outputPanel>
                                </p:fieldset>
                                <p:fieldset id="selectPersonelPoste" legend="Poste"  >

                                    <p:outputPanel id="dropAreaPoste">

                                        <h:outputText value="!!!Deplacer ici!!!"  
                                                      rendered="#{empty migrationdbaccessBean.personnelPosteT}"  
                                                      style="font-size:24px;" /> 
                                        <p:dataTable var="personnelAccess" 
                                                     paginator="true" rows="5"
                                                     rowsPerPageTemplate="5,10,15"
                                                     value="#{migrationdbaccessBean.personnelPosteT}"   
                                                     rendered="#{not empty migrationdbaccessBean.personnelPosteT}">  

                                            <p:column headerText="Matricule">  
                                                <h:outputText value="#{personnelAccess.IDpersonne}" />  
                                            </p:column>  

                                            <p:column headerText="Nom">  
                                                <h:outputText value="#{personnelAccess.nom}" />  
                                            </p:column>  

                                            <p:column headerText="Prenom">  
                                                <h:outputText value="#{personnelAccess.prenom}" />  
                                            </p:column>   

                                        </p:dataTable>  
                                    </p:outputPanel>
                                </p:fieldset>

                            </h:panelGrid>
                            <p:panelGrid columns="3">
                                <h:panelGrid columns="2">
                                    <p:outputLabel value="Compagnie : " for="compagnie" />  
                                    <p:selectOneMenu   id="compagnie"
                                                       style="width:150px" 
                                                       value="#{migrationdbaccessBean.affecteCompagnie}" converter="compagnieConverter"
                                                        filter="true" >   
                                        <f:selectItems value="#{travailleurBean.listeCompagnie}" var="compagnie" itemLabel="#{compagnie.nomcompagnie}" itemValue="#{compagnie}"/>  

                                    </p:selectOneMenu>
                                    <h:outputText />
                                    <p:commandButton value="Affecter le personnel à cette compagnie"
                                                     action="#{migrationdbaccessBean.nouvelleAffectionCompagnie}"
                                                    
                                                     >
                                        
                                    </p:commandButton>
                                </h:panelGrid>
                                <p:panelGrid columns="2" >
                                    <p:outputLabel value="Mission :" for="mission" />
                                    <p:selectOneMenu id="mission" style="width:200px"  value="#{travailleurBean.cvMission}" converter="missionConverter">  
                                        <f:selectItem itemLabel="Selectionne mission" itemValue="" />  
                                        <f:selectItems value="#{travailleurBean.listeMission}" var="mission" itemLabel="#{mission.idmission}" itemValue="#{mission}"/>  
                                        <p:ajax update="departement, equipe" 
                                                listener="#{travailleurBean.handleMissionChange}" />  
                                    </p:selectOneMenu>  

                                    <p:outputLabel value="Departement :" for="departement" />
                                    <p:selectOneMenu id="departement" style="width:200px"  value="#{travailleurBean.cvListedepartement}" converter="departementConverter">  
                                        <f:selectItem itemLabel="Selectionner departement" itemValue="" />  
                                        <f:selectItems value="#{travailleurBean.departementListeHand}" var="departement" itemLabel="#{departement.nomdepartement}" itemValue="#{departement}" />  
                                        <p:ajax update="equipe" 
                                                listener="#{travailleurBean.handleDepartementChange}" />
                                    </p:selectOneMenu> 

                                    <p:outputLabel value="Equipe :" for="equipe" />
                                    <p:selectOneMenu id="equipe" style="width:200px"  value="#{travailleurBean.cvEquipedepartement}" converter="equipeConverter">  
                                        <f:selectItem itemLabel="Selectionner équipe" itemValue="" />  
                                        <f:selectItems value="#{travailleurBean.equipeListeHand}" var="equipe" itemLabel="#{equipe.equipe}" itemValue="#{equipe}" />  
                                    </p:selectOneMenu> 

                                    <p:outputLabel value="Date d'affectation :" for="dateAffactation" />
                                    <p:calendar id="dateAffactation" value="#{travailleurBean.dateAffectation}"
                                                mindate="#{lesTravailleursBean.cvAffectationSelectionner.dateaffectation}"
                                                pattern="dd/MM/yyyy " title="Date d'affectation" 
                                                />
                                    <h:outputText />
                                    <p:commandButton value="Affecter le personnel à cette equipe" icon="ui-icon-check"
                                                     action="#{migrationdbaccessBean.nouvelleAffectionEquipe}"
                                                     >
                                        <f:setPropertyActionListener value="#{travailleurBean.cvEquipedepartement}" target="#{migrationdbaccessBean.affecteMission.cvEquipedepartementIdequipedepartement}"/>
                                        <f:setPropertyActionListener value="#{travailleurBean.dateAffectation}" target="#{migrationdbaccessBean.affecteMission.dateaffectation}"/>
                                    </p:commandButton>
                                </p:panelGrid>
                                 <p:panelGrid columns="2">
                                    <p:outputLabel value="Poste :" for="posteselectionner" />
                                    <p:selectOneMenu  id="posteselectionner"
                                                      style="width:200px"
                                                      value="#{travailleurBean.cvListeposte}" converter="listeposteConverter"
                                                       filter="true">   
                                        <f:selectItem itemLabel="Selectionner le poste" itemValue="" /> 
                                        <f:selectItems value="#{travailleurBean.listePoste}" var="poste" itemLabel="#{poste.poste}" itemValue="#{poste}"/>  

                                    </p:selectOneMenu>
                                    <h:outputText/>
                                    <p:commandButton value="Valider l'affectation" icon="ui-icon-check"
                                                     action="#{migrationdbaccessBean.nouvelleAffectionPoste}"
                                                     >
                                        <f:setPropertyActionListener value="#{travailleurBean.cvListeposte}" target="#{migrationdbaccessBean.cvPosteoccupeNouveau.cvListeposteIdposte}"/>
                                    </p:commandButton>
                                </p:panelGrid>
                            </p:panelGrid>
                            <p:droppable for="selectPersonelMission" tolerance="touch" 
                                         activeStyleClass="ui-state-highlight" datasource="availablePersonnelAccess"
                                         onDrop="handleDropM" >  
                                <p:ajax listener="#{migrationdbaccessBean.onPersonnelDropMissionT}" 
                                        update="dropAreaMission availablePersonnelAccess" />  
                            </p:droppable>  
                            <p:droppable for="selectPersonelAffectation" tolerance="touch" 
                                         activeStyleClass="ui-state-highlight" datasource="availablePersonnelAccess"
                                         onDrop="handleDropA" >  
                                <p:ajax listener="#{migrationdbaccessBean.onPersonnelDropAffectationT}" 
                                        update="dropAreaAffectation availablePersonnelAccess" />  
                            </p:droppable>  
                            <p:droppable for="selectPersonelPoste" tolerance="touch" 
                                         activeStyleClass="ui-state-highlight" datasource="availablePersonnelAccess"
                                         onDrop="handleDropP" >  
                                <p:ajax listener="#{migrationdbaccessBean.onPersonnelDropPosteT}" 
                                        update="dropAreaPoste availablePersonnelAccess" />  
                            </p:droppable>  

                            <!--</h:panelGrid>-->



                        </p:panel>
                    </h:form>
                    <script type="text/javascript">
                        function handleDropM(event, ui) {
                            ui.draggable.fadeOut('fast'); //fade out the dropped item
                        }
                        function handleDropA(event, ui) {
                            ui.draggable.fadeOut('fast'); //fade out the dropped item
                        }
                        function handleDropP(event, ui) {
                            ui.draggable.fadeOut('fast'); //fade out the dropped item
                        }

                    </script>
                </ui:define>
            </ui:composition>
        </h:body>

    </f:view>
</html>

